// pages/ledger/ledger.js
var fileManager = require('../../libs/fileManager');
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		authorLabel: '小赵同学',
		author: '0',
		money: "",
		purpose: ""
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {

	},
	insertLedgerData() {
		console.log(this.data)
		wx.showToast({
			image: "../../static/img/tuantuan1.png",
			title: '正在入账...',
			mask: true,
			duration: 3000
		})
		setTimeout(() => {
			fileManager.insertDataJS(this.data.purpose, this.data.money, this.data.author, this.data.authorLabel)
			this.setData({
				authorLabel: '小赵同学',
				author: '0',
				money: "",
				purpose: ""
			})
			wx.hideLoading()
		}, 3000);
	},
	// input伪双向绑定
	bindKeyInput: function (e) {
		this.setData({
			[e.target.dataset.vmodel]: e.detail.value
		})
	},
	goMenu() {
		console.log("前往入口页goMenu")
		wx.navigateTo({
			url: '/packageB/pages/menu/index',
		})
	},
	changeAuthor(e) {
		console.log(e)
		this.setData({
			author: e.currentTarget.dataset.value,
			authorLabel: e.currentTarget.dataset.value
		})
	}
})